package be.sbw.wave.extensions.publisher.model;

import java.util.HashMap;
import java.util.Set;

public class TextViewItem {
	
	public String Text;
	
	public Integer Position;
	
	public HashMap<String,String> Style;

	public TextViewItem(int pos, char charAt) {
		this.Position = pos;
		this.Text = ""+charAt;
		this.Style = new HashMap<String, String>();
	}
	
	public String getConcatenatedStyle(){
		String concatenatedOutput="";
		Set<String> set = Style.keySet();
		for(String key:set){
			concatenatedOutput+=key+Style.get(key);
		}
		return concatenatedOutput;
	}
	
	public String getHtmlStyle(){
		String result="";
		HashMap<String,String> supportedAnnotation = new HashMap<String,String>();
		supportedAnnotation.put("style/textDecoration", "text-decoration:{X}");
		supportedAnnotation.put("style/backgroundColor", "background-color:{X}");
		supportedAnnotation.put("style/fontFamily", "font-family:{X}");
		supportedAnnotation.put("style/color", "color:{X}");
		supportedAnnotation.put("style/fontSize", "font-size:{X}");
		Set<String> keys = this.Style.keySet();
		for(String key:keys){
			if(supportedAnnotation.containsKey(key)){
				result+=supportedAnnotation.get(key).replace("{X}",this.Style.get(key))+";";
			}
		}
		return result;
	}
}
